import { DEFAULT_SERVICE } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 系统管理模块
 */
// 获取菜单列表
export const getUserMenu = () => {
  return http.post<Menu.MenuOptions[]>(DEFAULT_SERVICE + `/sysSystem/getUserMenu`, {}, { loading: false });

  // 如果想让菜单变为本地数据，注释上一行代码，并引入本地 authMenuList.json 数据
  // const userStore = useUserStore();
  // if (userStore.userInfo.name === "superadmin") {
  //   systemMenuList.data.forEach(x => {
  //     authMenuList.data.push(x);
  //   });
  // }
  // return authMenuList;
};

// 获取数据字典值
export const getDictData = (dictType: string) => {
  return http.post(DEFAULT_SERVICE + `/sysSystem/getDictData`, { dictType }, { loading: false });
};

// 获取用户模块
export const getUserMod = () => {
  return http.post(DEFAULT_SERVICE + `/sysSystem/getUserMod`, {}, { loading: false });
};

// 获取字段数据源
export const getColumnDataSource = (params: { columnId: string }) => {
  return http.post<Array<any>>(DEFAULT_SERVICE + `/sysSystem/getColumnDataSource`, params);
};

// 获取自定义数据源
export const getCustomDataSource = (params: { dataSourceCode: string }) => {
  return http.post<Array<any>>(DEFAULT_SERVICE + `/sysSystem/getCustomDataSource`, params);
};
